package multimedia.control.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import multimedia.control.business.WebserviceDelegate;
	import multimedia.model.ModelLocator;
	import multimedia.util.LogUtil;
	
	import mx.logging.ILogger;
	import mx.logging.Log;
	import mx.rpc.IResponder;
	
	public class UpdateIPCommand implements ICommand, IResponder
	{
		
		private static const LOG:ILogger = LogUtil.getLogger(UpdateIPCommand);
		private var model:ModelLocator = ModelLocator.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
			var service:WebserviceDelegate = new WebserviceDelegate(this);
			service.updateIP(model.apiKey, model.playerId);
		}
		
		public function result(data:Object):void
		{
			LOG.info("updated IP to: " + data.result);
		}
		
		public function fault(info:Object):void
		{
			LOG.error("Could not update IP");
		}
	}
}